/*
 * $Id: RFSLogger.java
 * 
 * Copyright (C) 2010 General Electric Company. All Rights Reserved.
 * 
 * This software is the confidential and proprietary information of the General
 * Electric Company (GE). You shall not disclose this software and shall use it
 * only in accordance with the terms of the license agreement you entered into
 * with GE.
 * 
 * GE MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
 * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
 * NON-INFRINGEMENT. GE SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE
 * AS A RESULT OF USING, MODIFYING, OR DISTRIBUTING THIS SOFTWARE OR ITS
 * DERIVATIVES.
 */
package com.ge.healthcare.autosc.common.createrfs;

import org.apache.commons.logging.impl.Log4JLogger;
import org.apache.log4j.Logger;

/**
 * @author 212028625
 * 
 */
public class RFSLogger {
    private static final String METHOD_MES_SEP = "() : ";

    private static final String CLASS_METHOD_SEP = ".";

    /**
     * Logger class object
     */
    private static Logger logger = null;

    private static Log4JLogger log4j = null;

    static {
        logger = Logger.getLogger(com.ge.healthcare.autosc.common.createrfs.RFSLogger.class);
        log4j = new Log4JLogger(logger);
    }

    /**
     * @return - boolean indicating debug logging is enabled or not
     */
    public static boolean isDebugEnabled() {
        return log4j.isDebugEnabled();
    }

    /**
     * @return - boolean indicating info logging is enabled or not
     */
    public static boolean isInfoEnabled() {
        return log4j.isInfoEnabled();
    }

    /**
     * @return - boolean indicating trace logging is enabled or not
     */
    public static boolean isTraceEnabled() {
        return log4j.isTraceEnabled();
    }

    /**
     * @return - boolean indicating warn logging is enabled or not
     */
    public static boolean isWarnEnabled() {
        return log4j.isWarnEnabled();
    }

    /**
     * @return - boolean indicating error logging is enabled or not
     */
    public static boolean isErrorEnabled() {
        return log4j.isErrorEnabled();
    }

    /**
     * @return - boolean indicating fatal logging is enabled or not
     */
    public static boolean isFatalEnabled() {
        return log4j.isFatalEnabled();
    }

    /**
     * @param message
     */
    public static void debug(Object message) {
        logger.debug(message);
    }

    /**
     * @param message
     * @param t
     */
    public static void debug(Object message, Throwable t) {
        logger.debug(message, t);
    }

    /**
     * @param className
     * @param methodName
     * @param message
     */
    public static void debug(Class<?> className, String methodName, Object message) {
        StringBuffer logMessage = new StringBuffer();
        logMessage.append(className.getName()).append(CLASS_METHOD_SEP).append(methodName).append(METHOD_MES_SEP)
                .append(message.toString());
        debug(logMessage);
    }


    /**
     * @param className
     * @param methodName
     * @param message
     * @param t
     */
    public static void debug(Class<?> className, String methodName, Object message, Throwable t) {
        StringBuffer logMessage = new StringBuffer();
        logMessage.append(className.getName()).append(CLASS_METHOD_SEP).append(methodName).append(METHOD_MES_SEP)
                .append(message.toString());
        debug(logMessage, t);
    }

    /**
     * @param message
     */
    public static void info(Object message) {
        logger.info(message);
    }


    /**
     * @param message
     * @param t
     */
    public static void info(Object message, Throwable t) {
        logger.info(message, t);
    }


    /**
     * @param className
     * @param methodName
     * @param message
     */
    public static void info(Class<?> className, String methodName, Object message) {
        StringBuffer logMessage = new StringBuffer();
        logMessage.append(className.getName()).append(CLASS_METHOD_SEP).append(methodName).append(METHOD_MES_SEP)
                .append(message.toString());
        info(logMessage);
    }

    /**
     * @param className
     * @param methodName
     * @param message
     * @param t
     */
    public static void info(Class<?> className, String methodName, Object message, Throwable t) {
        StringBuffer logMessage = new StringBuffer();
        logMessage.append(className.getName()).append(CLASS_METHOD_SEP).append(methodName).append(METHOD_MES_SEP)
                .append(message.toString());
        info(logMessage, t);
    }

    /**
     * @param message
     */
    public static void warn(Object message) {
        logger.warn(message);
    }


    /**
     * @param message
     * @param t
     */
    public static void warn(Object message, Throwable t) {
        logger.warn(message, t);
    }

    public static void warn(Class<?> className, String methodName, Object message) {
        StringBuffer logMessage = new StringBuffer();
        logMessage.append(className.getName()).append(CLASS_METHOD_SEP).append(methodName).append(METHOD_MES_SEP)
                .append(message.toString());
        warn(logMessage);
    }

    /**
     * @param className
     * @param methodName
     * @param message
     * @param t
     */
    public static void warn(Class<?> className, String methodName, Object message, Throwable t) {
        StringBuffer logMessage = new StringBuffer();
        logMessage.append(className.getName()).append(CLASS_METHOD_SEP).append(methodName).append(METHOD_MES_SEP)
                .append(message.toString());
        warn(logMessage, t);
    }

    /**
     * @param message
     */
    public static void error(Object message) {
        logger.error(message);
    }

    /**
     * @param message
     * @param t
     */
    public static void error(Object message, Throwable t) {
        logger.error(message, t);
    }

    public static void error(Class<?> className, String methodName, Object message) {
        StringBuffer logMessage = new StringBuffer();
        logMessage.append(className.getName()).append(CLASS_METHOD_SEP).append(methodName).append(METHOD_MES_SEP)
                .append(message.toString());
        error(logMessage);
    }


    public static void error(Class<?> className, String methodName, Object message, Throwable t) {
        StringBuffer logMessage = new StringBuffer();
        logMessage.append(className.getName()).append(CLASS_METHOD_SEP).append(methodName).append(METHOD_MES_SEP)
                .append(message.toString());
        error(logMessage, t);
    }


    /**
     * @param message
     */
    public static void fatal(Object message) {
        logger.fatal(message);
    }


    /**
     * @param message
     * @param t
     */
    public static void fatal(Object message, Throwable t) {
        logger.fatal(message, t);
    }

    /**
     * @param className
     * @param methodName
     * @param message
     */
    public static void fatal(Class<?> className, String methodName, Object message) {
        StringBuffer logMessage = new StringBuffer();
        logMessage.append(className.getName()).append(CLASS_METHOD_SEP).append(methodName).append(METHOD_MES_SEP)
                .append(message.toString());
        fatal(logMessage);
    }


    /**
     * @param className
     * @param methodName
     * @param message
     * @param t
     */
    public static void fatal(Class<?> className, String methodName, Object message, Throwable t) {
        StringBuffer logMessage = new StringBuffer();
        logMessage.append(className.getName()).append(CLASS_METHOD_SEP).append(methodName).append(METHOD_MES_SEP)
                .append(message.toString());
        fatal(logMessage, t);
    }
}
